﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Tour.BLL;
using Tour.DAL;

public partial class Admin_Menu_MenuTypeList : VST.Controls.BaseLCGPage
{
    public int? ParentId { get; set; }
    public bool? IsVisible { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }


    void LoadData()
    {
        grv.DataSource = TblMenuTypeManager.CreateInstant().SelectAll();
        grv.DataBind();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string Url = string.Format("MenuTypeList.aspx?ParentId={0}&IsVisible={1}", ParentId, IsVisible);
        //string Url = string.Format("TblChannelList.aspx?ParentID={0}", ParentID);
        Response.Redirect(Url);
    }
    protected void grv_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        var hdfID = (HiddenField)grv.Rows[e.RowIndex].FindControl("hdfID");
        //var hdfParentId = (HiddenField)grv.Rows[e.RowIndex].FindControl("hdfParentID");
        try
        {
            //UpdateOrderOffAndDelete(hdfID.Value, hdfParentId.Value, 100);
            TblMenuTypeManager.CreateInstant().Delete(hdfID.Value.ToInt());
            Response.Redirect(Request.RawUrl);
            Trace.Warn("Delete Success" + hdfID.Value);
        }
        catch (Exception ex)
        {
            Trace.Warn("Delete Error" + hdfID.Value + ex.Message);
        }
        LoadData();
        Response.Redirect(Request.RawUrl);
    }
   
   
    protected void grv_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {//
        grv.PageIndex = e.NewPageIndex;
        LoadData();
    }
}